<template>
  <div class="container">
    <flexbox class="t-section" align="center">
      <img :src="crmIcon" class="t-section__hd" />
      <div class="t-section__bd">
        <!-- <div class="type-name">{{ typeName }}</div> -->
        <p class="name">
          <el-tooltip
            :disabled="!name"
            :content="name"
            effect="dark"
            placement="top-start"
          >
            <span>{{ name }}</span> </el-tooltip
          ><slot name="name" />
        </p>
      </div>
      <div class="t-section__ft">
        <el-button
          v-if="showTransfer"
          class="head-handle-button"
          type="primary"
          icon="wk wk-transfer"
          @click.native="handleTypeClick('transfer')"
          >转移</el-button
        >

        <el-button
          v-if="showEdit"
          class="head-handle-button"
          icon="el-icon-edit"
          type="primary"
          @click.native="handleTypeClick('edit')"
          >编辑</el-button
        >
        <el-button
          type="success"
          icon="el-icon-plus"
          @click="createReturnMoney"
          v-if="showCreateBtn"
          >新建回款</el-button
        >
        <el-button
          v-if="showGet"
          class="head-handle-button"
          icon="wk wk-receive"
          type="primary"
          @click.native="handleTypeClick('get')"
          >领取</el-button
        >

        <el-button
          v-if="showAlloc"
          class="head-handle-button xr-btn--green"
          type="primary"
          icon="wk wk-alloc"
          @click.native="handleTypeClick('alloc')"
          >分配</el-button
        >

        <el-button
          v-if="showDealStatus"
          class="head-handle-button"
          type="primary"
          icon="wk wk-success"
          @click.native="handleTypeClick('deal_status')"
          >更改成交状态</el-button
        >
        <!-- 回款审核 退款审核 合同审核 -->
        <el-button
          type="primary"
          v-if="
            examineInfo.isCheck == 1 &&
              (crmType == 'receivables' ||
                crmType == 'refund' ||
                crmType == 'contract')
          "
          class="create-btn"
          @click.native="handleTypeClick('submit_receivables')"
          >通过</el-button
        >
        <el-button
          type="danger"
          v-if="
            examineInfo.isCheck == 1 &&
              (crmType == 'receivables' ||
                crmType == 'refund' ||
                crmType == 'contract')
          "
          class="danger-btn"
          @click.native="handleTypeClick('dedanger_receivables')"
          >拒绝</el-button
        >
        <el-button
          type="danger"
          v-if="
            examineInfo.isRecheck == 1 &&
              (crmType == 'receivables' ||
                crmType == 'refund' ||
                crmType == 'contract')
          "
          class="danger-btn"
          @click.native="handleTypeClick('recall_receivables')"
          >撤回</el-button
        >
        <el-button
          type="primary"
          v-if="
            detail.checkStatus == 1 &&
              (crmType == 'receivables' ||
                (crmType == 'refund' && detail.refundCategory != '账单退款') ||
                crmType == 'contract')
          "
          class="create-btn"
          style="cursor: default"
          >审核已通过</el-button
        >
        <el-button
          type="danger"
          v-if="
            detail.checkStatus == 2 &&
              (crmType == 'receivables' ||
                crmType == 'refund' ||
                crmType == 'contract')
          "
          class="danger-btn"
          style="cursor: default"
          >审核已拒绝</el-button
        >

        <el-dropdown
          v-if="permissionMoreTypes && permissionMoreTypes.length > 0"
          trigger="click"
          @command="handleTypeClick"
        >
          <el-button icon="el-icon-more" class="t-more" />
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item
              v-for="(item, index) in permissionMoreTypes"
              :key="index"
              :icon="item.icon | wkIconPre"
              :command="item.type"
              >{{ item.name }}</el-dropdown-item
            >
          </el-dropdown-menu>
        </el-dropdown>

        <el-button class="close-btn" icon="el-icon-close" @click="close" />
      </div>
    </flexbox>
    <flexbox class="h-section" align="stretch">
      <flexbox-item
        v-for="(item, index) in headDetails"
        v-show="item.title"
        :key="index"
        class="h-item"
      >
        <div class="h-title">{{ item.title }}</div>
        <div
          class="h-value text-one-line"
          :class="item.value == '高风险' ? 'is_red' : ''"
        >
          <i v-if="item.showIcon" :style="item.style" :class="item.icon" />{{
            item.value ? item.value : "--"
          }}
        </div>
      </flexbox-item>
    </flexbox>
    <slot />
    <transfer-handle
      :crm-type="crmType"
      :selection-list="[detail]"
      :dialog-visible.sync="transferDialogShow"
      @handle="handleCallBack"
    />
    <transform-handle
      :crm-type="crmType"
      :selection-list="[detail]"
      :dialog-visible.sync="transformDialogShow"
      :transformTeacherList="transformTeacherList"
      @handle="handleCallBack"
    />
    <alloc-handle
      :crm-type="crmType"
      :pool-id="poolId"
      :selection-list="[detail]"
      :dialog-visible.sync="allocDialogShow"
      @handle="handleCallBack"
    />
    <deal-status-handle
      :value="
        crmType == 'contract'
          ? detail.dealStatus == '已成交'
            ? 1
            : 0
          : detail.dealStatus
      "
      :crm-type="crmType"
      :selection-list="[detail]"
      :visible.sync="dealStatusShow"
      @handle="handleCallBack"
    />
    <put-pool-handle
      :visible.sync="putPoolShow"
      :selection-list="[detail]"
      @handle="handleCallBack"
    />

    <submit-refund
      :visible.sync="submitRefundShow"
      :selection-list="[detail]"
      @handle="handleCallBack"
    />

    <dedanger-refund
      :visible.sync="dedangerRefundShow"
      :selection-list="[detail]"
      @handle="handleCallBack"
    />
    <examine-handle
      :show="showExamineHandle"
      :id="id"
      :record-id="detail.examineRecordId"
      :examine-type="examineType"
      :detail="examineInfo"
      :status="examineHandleInfo.status"
      @close="showExamineHandle = false"
      @save="examineHandleClick"
      v-if="showExamineHandle"
    />
    <c-r-m-all-create
      v-if="isCreate"
      :crm-type="createCrmType"
      :action="createActionInfo"
      @save-success="saveSuccess"
      @close="isCreate = false"
    />
    <!-- -->
  </div>
</template>
<script type="text/javascript">
import { mapGetters } from "vuex";
import { crmLeadsTransformAPI, crmLeadsDeleteAPI } from "@/api/crm/leads";
import {
  crmCustomerLockAPI,
  crmCustomerDeleteAPI,
  crmCustomerPoolDeleteAPI,
  crmCustomerReceiveAPI
} from "@/api/crm/customer";
import {
  crmCustomerVipLockAPI,
  crmCustomerVipDeleteAPI,
  crmCustomerVipReceiveAPI
} from "@/api/crm/vipStudents";
import { crmContactsDeleteAPI } from "@/api/crm/contacts";
import { crmBusinessDeleteAPI } from "@/api/crm/business";
import { crmContractDeleteAPI, crmContractCancelAPI } from "@/api/crm/contract";
import { crmReceivablesDeleteAPI } from "@/api/crm/receivables";
import { crmReturnVisitDeleteAPI } from "@/api/crm/visit";
import { crmProductStatusAPI, crmProductDeleteAPI } from "@/api/crm/product";
import { crmInvoiceDeleteIdsAPI } from "@/api/crm/invoice";
import TransferHandle from "./SelectionHandle/TransferHandle"; // 转移
import TransformHandle from "./SelectionHandle/TransformHandle"; // 转化为学员
import AllocHandle from "./SelectionHandle/AllocHandle"; // 公海分配操作
import DealStatusHandle from "./SelectionHandle/DealStatusHandle"; // 学员状态修改操作
import PutPoolHandle from "./SelectionHandle/PutPoolHandle"; // 放入公海
import SubmitRefund from "./SelectionHandle/SubmitRefund"; // 退款确认
import DedangerRefund from "./SelectionHandle/dedangerRefund"; // 退款拒绝
import { examineRecordQueryListAPI } from "@/api/examine"; // 审批步骤
import ExamineHandle from "@/components/Examine/ExamineHandle"; // 审批操作理由
import {
  queryTrainingStatusAPI,
  queryTeacherListForLeadsAPI
} from "@/api/admin/training";
import CRMAllCreate from "../components/CRMAllCreate"; // 新建页面
import { objDeepCopy } from "@/utils";
export default {
  name: "CRMDetailHead",
  components: {
    TransferHandle,
    TransformHandle,
    AllocHandle,
    DealStatusHandle,
    PutPoolHandle,
    SubmitRefund,
    DedangerRefund,
    ExamineHandle,
    CRMAllCreate
  },
  props: {
    /** 模块ID */
    id: [String, Number],
    poolId: [String, Number],
    // 公海权限
    poolAuth: Object,
    /** 没有值就是全部类型 有值就是当个类型 */
    crmType: {
      type: String,
      default: ""
    },
    // 辅助 使用
    isSeas: {
      type: Boolean,
      default: false
    },
    /** 联系人人下 新建商机 需要联系人里的学员信息  合同下需要学员和商机信息 合同作废需要合同状态*/
    detail: {
      type: Object,
      default: () => {
        return {};
      }
    },
    headDetails: {
      type: Array,
      default: () => {
        return [];
      }
    }
  },
  data() {
    return {
      moreTypes: [], // 更多操作
      transferDialogShow: false, // 转移操作
      transformDialogShow: false,
      allocDialogShow: false, // 公海分配操作提示框
      dealStatusShow: false, // 成交状态修改框
      putPoolShow: false, // 学员放入公海
      submitRefundShow: false, // 退款确认
      dedangerRefundShow: false, // 退款拒绝
      examineInfo: {}, //审批流信息
      examineStatus: -1, //审批流状态
      showExamineHandle: false,
      examineHandleInfo: { status: 1 },
      examineType: "",
      transformTeacherList: [],
      isCreate: false,
      createCrmType: "receivables" // 创建回款计划
    };
  },
  computed: {
    ...mapGetters(["crm"]),
    showCreateBtn() {
      if (
        this.crmType == "contract" &&
        this.crm &&
        this.crm["receivables"] &&
        this.crm["receivables"].save &&
        this.detail.contractCategory != "账单合同"
      ) {
        return true;
      }
      return false;
    },
    crmIcon() {
      return require(`@/assets/router/${
        this.crmType == "customer"
          ? "student"
          : this.crmType == "vipStudents"
          ? "vipstudent"
          : this.crmType
      }_select.svg`);
    },
    typeName() {
      return (
        {
          leads: "线索",
          customer: "学员",
          contacts: "联系人",
          product: "产品",
          business: "商机",
          contract: "合同",
          receivables: "回款",
          refund: "退款",
          visit: "回访",
          invoice: "发票",
          vipStudents: "VIP学员",
          overdue: "逾期"
        }[this.crmType] || ""
      );
    },
    name() {
      if (this.crmType === "receivables") {
        return this.detail.number;
      } else if (this.crmType === "refund") {
        return this.detail.number;
      } else if (
        this.crmType === "customer" ||
        this.crmType === "leads" ||
        this.crmType === "vipStudents"
      ) {
        return this.detail.customerName;
      } else if (this.crmType === "business") {
        return this.detail.businessName;
      } else if (this.crmType === "visit") {
        return this.detail.visitNumber;
      } else if (this.crmType === "invoice") {
        return this.detail.invoiceApplyNumber;
      }
      return this.detail.name;
    },
    // 展示转移
    showTransfer() {
      if (
        ["customer", "visit", "refund"].includes(this.crmType) ||
        this.isSeas
      ) {
        return false;
      }

      if (this.crmType === "contract") {
        return (
          this.detail &&
          this.detail.checkStatus != 8 &&
          this.crm[this.crmType].transfer
        );
      }
      if (this.crmType === "refund") {
        if (!this.crm[this.crmType]) {
          return false;
        }
      }

      return this.crm[this.crmType].transfer;
    },
    showEdit() {
      if (this.crmType === "refund") {
        if (
          !this.crm[this.crmType] ||
          this.detail.refundCategory == "账单退款"
        ) {
          return false;
        }
      }
      if (this.crmType == "contract") {
        if (this.detail.type == "三方账单") {
          return false;
        }
      }
      // console.log("this.crm[this.crmType].update", this.headDetails,this.detail)
      //  8 已作废 的合同可以编辑
      return this.isSeas ||
        (this.detail.isTransform == 1 &&
          !this.$store.state.user.userInfo.isAdmin)
        ? false
        : this.crm[this.crmType].update; // 可以更新 并且退款在草稿状态
    },

    // 展示领取
    showGet() {
      return this.isSeas && this.whetherTypeShowByPermision("get");
    },

    // 展示分配
    showAlloc() {
      return this.isSeas && this.whetherTypeShowByPermision("alloc");
    },

    /**
     * 学员是否锁定
     */
    isLock() {
      if (this.detail) {
        return this.detail.status == 2; // 1是正常 2 是锁定
      }
      return false;
    },

    /**
     * 展示成交按钮
     */
    showDealStatus() {
      return false;
    },

    /**
     * 权限内的更多按钮
     */
    permissionMoreTypes() {
      return this.moreTypes.filter(item => {
        return this.whetherTypeShowByPermision(item.type);
      });
    }
  },
  watch: {
    isSeas() {
      this.moreTypes = this.getSelectionHandleItemsInfo();
    },
    detail(val) {
      console.log("detail-watch", val);
    }
  },
  mounted() {
    console.log("测试打印123-------------------detail");
    console.log(this.detail);
    this.moreTypes = this.getSelectionHandleItemsInfo();
    if (
      this.detail &&
      this.detail.examineRecordId &&
      (this.crmType == "refund" ||
        this.crmType == "receivables" ||
        this.crmType == "contract")
    ) {
      this.getExamineRecordList();
    }
  },
  methods: {
    saveSuccess() {
      this.$bus.emit("crm-tab-num-update");
      this.$bus.emit("crm-return-list-update");
    },
    createReturnMoney() {
      this.createActionInfo = {
        type: "relative",
        crmType: this.crmType,
        data: {}
      };
      this.createActionInfo.data["customer"] = objDeepCopy(this.detail);
      this.createActionInfo.data["contract"] = objDeepCopy(this.detail);
      this.isCreate = true;
    },
    examineHandleClick(data) {
      this.$bus.emit("unDoingThing", "visible");
      this.getExamineRecordList();
      // this.getFlowStepList();
      // if (this.$refs.checkFlow) {
      //   this.$refs.checkFlow.getDetail();
      // }
      // this.$emit("on-handle", data);
    },
    getExamineRecordList() {
      examineRecordQueryListAPI({
        recordId: this.detail.examineRecordId,
        ownerUserId: this.detail.ownerUserId
      }).then(res => {
        const resData = res.data || {};
        this.examineInfo = resData;
        if (
          this.examineInfo.examineFlowList &&
          this.examineInfo.examineFlowList.length > 0
        ) {
          let examineFlowList = this.examineInfo.examineFlowList[
            this.examineInfo.examineFlowList.length - 1
          ];
          this.examineStatus = examineFlowList.examineStatus;
        }
      });
    },
    /** 更多操作 */
    handleTypeClick(type, examineType) {
      if (this.crmType == "receivables") {
        this.examineType = "crm_receivables";
      } else if (this.crmType == "refund") {
        this.examineType = "crm_refund";
      } else if (this.crmType == "contract") {
        this.examineType = "crm_contract";
      }
      if (type == "submit_receivables") {
        //审核通过
        this.examineHandleInfo.status = 1;
        this.showExamineHandle = true;
      } else if (type == "dedanger_receivables") {
        //审核拒绝
        this.examineHandleInfo.status = 2;
        this.showExamineHandle = true;
      } else if (type == "recall_receivables") {
        //审核撤回
        this.examineHandleInfo.status = 4;
        this.showExamineHandle = true;
      } else if (type == "edit") {
        // 编辑
        this.$emit("handle", { type: "edit" });
      } else if (type == "transfer") {
        // 转移
        this.transferDialogShow = true;
      } else if (type == "transform") {
        // 转化学员操作
        queryTrainingStatusAPI().then(res1 => {
          if (res1.data == 1) {
            //训练营模式开启
            this.teamsTitle = "转化学员填写字段";
            this.transformDialogShow = true;
            queryTeacherListForLeadsAPI().then(res => {
              this.transformTeacherList = res.data.list || [];
            });
          } else {
            //训练营模式关闭
            this.$confirm(
              `确认将客户 “ ${this.detail.customerName} ” 转化为学员吗？`,
              "提示",
              {
                confirmButtonText: "确定",
                cancelButtonText: "取消",
                type: "warning"
              }
            )
              .then(() => {
                crmLeadsTransformAPI({
                  leadsIds: [this.detail.leadsId]
                }).then(ress => {
                  if (ress.code == 0) {
                    this.$message({
                      type: "success",
                      message: "操作成功"
                    });
                    this.handleCallBack({ type: "transfer" });
                  } else {
                    this.$message({
                      type: "error",
                      message: res.msg
                    });
                  }
                });
              })
              .catch(() => {});
          }
        });
      } else if (
        type == "transform" ||
        type == "delete" ||
        type == "lock" ||
        type == "unlock" ||
        type == "start" ||
        type == "disable" ||
        type == "get" ||
        type == "cancel"
      ) {
        var message = "";
        if (type == "delete") {
          message = this.isSeas
            ? "若学员下有联系人，联系人将一并删除。确定删除？"
            : "确定删除?";
        } else if (type == "lock") {
          message = "确定要锁定该学员吗？锁定后将不会掉入公海。";
        } else if (type == "unlock") {
          message = "确定要解锁该学员吗？";
        } else if (type == "start") {
          message = "确定要上架该产品吗?";
        } else if (type == "disable") {
          message = "确定要下架该产品吗?";
        } else if (type == "get") {
          message = "确定要领取该学员吗?";
        } else if (type == "cancel") {
          message = "确定要作废此合同吗?";
          if (this.detail.receivablesCount) {
            message = "合同下有相关回款,确定要作废吗?";
          }
        }

        this.$confirm(message, "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        })
          .then(() => {
            this.confirmHandle(type);
          })
          .catch(() => {});
      } else if (type == "alloc") {
        // 公海分配操作
        this.allocDialogShow = true;
      } else if (type == "deal_status") {
        // 学员成交状态操作
        this.dealStatusShow = true;
      } else if (type == "put_seas") {
        // 学员放入公海
        this.putPoolShow = true;
      } else if (type == "print") {
        // 打印
        const id = this.detail[`${this.crmType}Id`];
        const routeData = this.$router.resolve(
          `/print/?module=${this.crmType}&id=${id}`
        );
        window.open(routeData.href, "_blank");
      } else if (type == "copyContract") {
        this.$emit("handle-click", { type });
      } else if (type == "dedanger_refund") {
        // 退款审核通过
        this.dedangerRefundShow = true;
      } else if (type == "submit_refund") {
        // 退款审核拒绝
        this.submitRefundShow = true;
      }
    },
    confirmHandle(type) {
      if (type === "lock" || type === "unlock") {
        crmCustomerLockAPI({
          status: type === "lock" ? "2" : "1", // 1是正常 2 是锁定
          ids: this.id
        })
          .then(res => {
            this.$message({
              type: "success",
              message: "操作成功"
            });
            this.$emit("handle", { type: type });
          })
          .catch(() => {});
      } else if (type === "transform") {
        crmLeadsTransformAPI([this.id])
          .then(res => {
            this.$message({
              type: "success",
              message: "转化成功"
            });
            // 刷新待办
            this.$store.dispatch("GetMessageNum");

            this.$emit("handle", { type: type });
          })
          .catch(() => {});
      } else if (type === "start" || type === "disable") {
        crmProductStatusAPI({
          ids: [this.id],
          status: type === "start" ? "1" : "0"
        })
          .then(res => {
            this.$message({
              type: "success",
              message: "操作成功"
            });
            this.$emit("handle", { type: type });
          })
          .catch(() => {});
      } else if (type === "delete") {
        const request = {
          leads: crmLeadsDeleteAPI,
          customer: this.isSeas
            ? crmCustomerPoolDeleteAPI
            : crmCustomerDeleteAPI,
          contacts: crmContactsDeleteAPI,
          business: crmBusinessDeleteAPI,
          contract: crmContractDeleteAPI,
          receivables: crmReceivablesDeleteAPI,
          visit: crmReturnVisitDeleteAPI,
          product: crmProductDeleteAPI,
          invoice: crmInvoiceDeleteIdsAPI,
          vipStudents: crmCustomerVipDeleteAPI
        }[this.crmType];
        const params = {};
        if (this.isSeas) {
          params.poolId = this.poolId;
        }
        params.ids = [parseInt(this.id)];
        request(this.isSeas ? params : params.ids)
          .then(res => {
            this.$message({
              type: "success",
              message: "删除成功"
            });
            this.$emit("handle", { type: type });
          })
          .catch(() => {});
      } else if (type === "get") {
        // 领取
        crmCustomerReceiveAPI({
          ids: [this.id],
          poolId: this.poolId
        })
          .then(res => {
            this.$message({
              type: "success",
              message: "操作成功"
            });
            // 刷新待办
            this.$store.dispatch("GetMessageNum");

            this.$emit("handle", { type: type });
          })
          .catch(() => {});
      } else if (type === "cancel") {
        crmContractCancelAPI({
          contractId: this.id
        })
          .then(res => {
            this.$message.success("操作成功");
            this.$emit("handle", { type });
          })
          .catch(() => {});
      }
    },
    // 子组件 回调的 结果
    handleCallBack(data) {
      this.$emit("handle", { type: data.type });
    },

    /** 更多操作 */
    /** 获取展示items */
    getSelectionHandleItemsInfo() {
      const handleInfos = {
        transfer: {
          name: "转移",
          type: "transfer",
          icon: "transfer"
        },
        transform: {
          name: "转化为学员",
          type: "transform",
          icon: "transform"
        },
        export: {
          name: "导出选中",
          type: "export",
          icon: "export"
        },
        delete: {
          name: "删除",
          type: "delete",
          icon: "delete"
        },
        put_seas: {
          name: "放入公海",
          type: "put_seas",
          icon: "seas"
        },
        lock: {
          name: "锁定",
          type: "lock",
          icon: "lock"
        },
        unlock: {
          name: "解锁",
          type: "unlock",
          icon: "unlock"
        },
        add_user: {
          name: "添加团队成员",
          type: "add_user",
          icon: "add"
        },
        delete_user: {
          name: "移除团队成员",
          type: "delete_user",
          icon: "remove"
        },
        alloc: {
          name: "分配",
          type: "alloc",
          icon: "alloc"
        },
        get: {
          name: "领取",
          type: "get",
          icon: "receive"
        },
        start: {
          name: "上架",
          type: "start",
          icon: "shelves"
        },
        disable: {
          name: "下架",
          type: "disable",
          icon: "sold-out"
        },
        deal_status: {
          name: "更改成交状态",
          type: "deal_status",
          icon: "s-status"
        },
        cancel: {
          name: "合同作废",
          type: "cancel",
          icon: "invalid"
        },
        print: {
          name: "打印",
          type: "print",
          icon: "print"
        },
        copyContract: {
          name: "复制合同",
          type: "copyContract",
          icon: "icon-double-note"
        }
      };
      if (this.crmType == "leads") {
        return this.forSelectionHandleItems(handleInfos, [
          "transform",
          "delete"
        ]);
      } else if (this.crmType == "customer") {
        if (this.isSeas) {
          return this.forSelectionHandleItems(handleInfos, ["delete"]);
        } else {
          return this.forSelectionHandleItems(handleInfos, [
            "transfer",
            // "put_seas",
            // "lock",
            // "unlock",
            "delete"
          ]);
        }
      } else if (this.crmType == "contacts") {
        return this.forSelectionHandleItems(handleInfos, ["delete"]);
      } else if (this.crmType == "business") {
        return this.forSelectionHandleItems(handleInfos, [
          // "print",
          "delete"
        ]);
      } else if (this.crmType == "contract") {
        if (this.detail.type == "三方账单") {
          return [];
        }
        return this.forSelectionHandleItems(handleInfos, [
          // "print",
          "delete",
          "cancel"
          // "copyContract",
        ]);
      } else if (this.crmType == "receivables") {
        return this.forSelectionHandleItems(handleInfos, [
          // "print",
          "delete"
        ]);
      } else if (this.crmType == "product") {
        return this.forSelectionHandleItems(handleInfos, [
          "delete",
          "start",
          "disable"
        ]);
      } else if (this.crmType == "visit") {
        return this.forSelectionHandleItems(handleInfos, ["delete"]);
      } else if (this.crmType == "invoice") {
        return this.forSelectionHandleItems(handleInfos, ["delete"]);
      }
      return [];
    },
    forSelectionHandleItems(handleInfos, array) {
      var tempsHandles = [];
      for (let index = 0; index < array.length; index++) {
        tempsHandles.push(handleInfos[array[index]]);
      }
      return tempsHandles;
    },
    // 判断是否展示
    whetherTypeShowByPermision(type) {
      if (type == "transfer") {
        return this.crm[this.crmType].transfer;
      } else if (type == "transform") {
        return this.crm[this.crmType].transform;
      } else if (type == "export") {
        if (this.isSeas) {
          if (this.poolId) {
            return this.poolAuth.excelexport;
          }
          return this.crm.pool && this.crm.pool.excelexport;
        }
        return this.crm[this.crmType].excelexport;
      } else if (type == "delete") {
        if (this.isSeas) {
          if (this.poolId) {
            return this.poolAuth && this.poolAuth.delete;
          }
          return this.crm.pool && this.crm.pool.delete && this.poolId;
        }
        return this.crm[this.crmType].delete;
      } else if (type == "put_seas") {
        // 放入公海(学员)
        return this.crm[this.crmType].putinpool;
      } else if (type == "lock" || type == "unlock") {
        // 锁定解锁(学员)
        return this.crm[this.crmType].lock;
      } else if (type == "add_user" || type == "delete_user") {
        // 添加 移除团队成员
        return this.crm[this.crmType].teamsave;
      } else if (type == "alloc") {
        // 分配(公海)
        if (this.poolId) {
          return this.poolAuth && this.poolAuth.distribute;
        }
        return this.crm.pool && this.crm.pool.distribute;
      } else if (type == "get") {
        // 领取(公海)
        if (this.poolId) {
          return this.poolAuth && this.poolAuth.receive;
        }
        return this.crm.pool && this.crm.pool.receive && this.poolId;
      } else if (type == "start" || type == "disable") {
        // 上架 下架(产品)
        return this.crm[this.crmType].status;
      } else if (type == "deal_status") {
        // 学员状态修改
        return this.crm[this.crmType].dealStatus;
      } else if (type == "cancel") {
        // 合同作废
        if (this.crm[this.crmType].discard && this.detail.checkStatus === 1) {
          return true;
        }
        return false;
      } else if (type == "print") {
        // 打印
        return this.crm[this.crmType].print;
      } else if (type == "copyContract") {
        // 合同复制
        return this.crm[this.crmType].save;
      }

      return true;
    },
    // 关闭
    close() {
      this.$emit("close");
    }
  }
};
</script>
<style lang="scss" scoped>
.container {
  position: relative;
  background-color: white;
}

.t-section {
  position: relative;
  padding: 17px 0px 17px;
  min-height: 60px;
  &__hd {
    display: block;
    width: 20px;
    height: 20px;
    margin-right: 11px;
  }

  &__bd {
    flex: 1;
    .type-name {
      color: #999;
      font-size: 12px;
      margin-bottom: 5px;
    }

    .name {
      color: #333;
      font-size: 16px;
      font-weight: 600;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 1;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }
  }

  &__ft {
    flex-shrink: 0;
    margin-left: 20px;
    display: flex;
    align-items: center;
    .close-btn {
      border: none;
      font-size: 26px;
    }
    .close-btn:hover {
      background-color: transparent;
      color: #333;
    }
  }

  .t-more {
    margin-left: 15px;
  }

  .t-close {
    display: block;
    width: 40px;
    height: 40px;
    margin-left: 20px;
    padding: 10px;
    cursor: pointer;
  }
}

.h-section {
  position: relative;
  padding: 23px 0px;
  border-top: 1px solid #e5e5e5;
  box-sizing: border-box;
  .h-item {
    .h-title {
      font-size: 14px;
      color: #333;
    }
    .h-value {
      min-height: 14px;
      margin-top: 16px;
      font-size: 13px;
      color: #666;
      padding-bottom: 2px;
    }
  }
}

.create-btn {
  background: #07bf50;
  border-color: #07bf50;
  border-radius: 4px;
  color: #fff;
  padding: 8px 20px;
}

.danger-btn {
  background: #ff3535;
  border-color: #ff3535;
  border-radius: 4px;
  color: #fff;
  padding: 8px 20px;
}

.el-button + .el-button {
  margin-left: 15px;
}

.head-handle-button {
  /deep/ i {
    font-size: 13px;
    margin-right: 5px;
  }
}
.is_red {
  color: #ff6161 !important;
}
</style>
